package com.comp;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:周次煜
 * Date: 2024-03-06
 * Time：18:48
 */

public class Student implements Comparable<Student> {
    public String name;
    public int age;
    public double score;

    public Student(String name, int age, double score) {
        this.name = name;
        this.age = age;
        this.score = score;
    }

//    @Override
////     学生年龄比较
//    public int compareTo(Student o) {
//        if (this.age > o.age) {
//            return 1;
//        } else if (this.age < o.age) {
//            return -1;
//        } else {
//            return 0;
//        }
//    }
//
    // 学生姓名比较
    public int compareTo(Student o) {
       if (this.name.compareTo(o.name)>0) {
           return 1;
       } else if (this.name.compareTo(o.name)<0) {
           return -1;
       } else {
           return 0;
       }
    }
}

//class Test {
//    public static void main(String[] args) {
//        Student s1 =new Student("郭灵杰",19,98.5);
//        Student s2=new Student("钟祥",18,99.5);
//        int ret = s1.compareTo(s2);
//        if (ret >0)  {
//            System.out.println(s1.name+" 比 "+s2.name+" 年龄更大！ ");
//        } else if (ret <0 ) {
//            System.out.println(s1.name+" 比 "+s2.name+" 年龄更小！ ");
//        } else {
//            System.out.println(s1.name+" 比 "+s2.name+" 年龄一样大！ ");
//        }
//    }
//}

class Test {
    public static void main3(String[] args) {

        Student s1 =new Student("郭灵杰",19,98.5);
        Student s2=new Student("钟祥",18,99.5);

        int ret = s1.compareTo(s2);

        if (ret >0)  {
            System.out.println(s1.name+" 比 "+s2.name+" 拼音更复杂！ ");
        } else if (ret <0 ) {
            System.out.println(s1.name+" 比 "+s2.name+" 拼音更简单！ ");
        } else {
            System.out.println(s1.name+" 比 "+s2.name+" 拼音一样！ ");
        }
    }


}


